<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@page import="com.tln.sys.menu.model.Menu"%>
<%@ include file="/commons/taglibs.jsp" %>
<%@ include file="/commons/commonjs.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>

<head>
	<base href="<%=basePath%>">
	<title><%=Menu.TABLE_ALIAS%>新增</title>
	<script type="text/javascript">
		$(document).ready(function(){
			if(${done}=='1'){
				//Dialog.alert("保存成功！");
				Dialog.alert('修改成功',function(){
					var frames = topWin.frames;	//topWin.parent.frames	
					frames[0].mygrid.reload();
					parentDialog.close();
				},150,50);	
			}
		})
		
		function openTree(parentId){
		   //alert(parentId);
			var diag = new Dialog();
			diag.Modal = false;
			diag.Width = 200;
			diag.Height = 500;
			diag.Title = "返回值到调用页面";
			diag.URL = "/sys/menu/dyTree/"+parentId;// /jsp/test.jsp   /sys/dialog/test/2
			diag.OKEvent = function(){
				var doc = diag.innerFrame.contentWindow.document;
				//alert(diag.innerFrame.contentWindow.tree.nodes); 
				var IDs="";
				var content = "";
				
				//selectedNode(选择的节点)  , nodes 
				//diag.innerFrame.contentWindow.tree.selectedNode;
				
			    var nodes = diag.innerFrame.contentWindow.tree.selectedNode;
			    alert(nodes.text);
			    /*for(var i in nodes) {
			        if(nodes[i].checked){
			            //text = nodes[i].text;
			            content += nodes[i].text + ","; //name
			            IDs +=nodes[i].id + ","; //id
			            
			        }
			    }*/
			    //alert(content);
			    //alert(IDs);添加一节点，
			    //diag.innerFrame.contentWindow.tree.appendNode(nodes.id, 'text: new node;')
				
				$id('parentName').value = nodes.text;
				$id('parentId').value = nodes.id;
				//alert(a);
				//$id('parentId').value = diag.innerFrame.contentWindow.document.getElementById('a').value;
				diag.close();
			};
			diag.show();
			/*var doc=diag.innerFrame.contentWindow.document;
			doc.open();
			doc.write('<html><body><input id="a" type="text"/>请在文本框里输入一些值</body></html>') ;
			doc.close();*/
		}
	</script>
</head>

<body>
<%@ include file="/commons/messages.jsp" %>
<%-- /sys/menu/{id}/edit --%>
<form:form method="put" action="${ctx}/sys/menu/${menu.id}" modelAttribute="menu">
	<input id="submitButton" name="submitButton" type="submit" value="提交" />
	<input onClick="parentDialog.close();" type="button" value="关闭" />
	<input type="button" value="后退" onclick="history.back();"/>
	
	<table class="formTable">
	<input type="hidden" id="id" name="id" value="${menu.id}"/>

	<tr>	
		<td class="tdLabel">
			<%=Menu.ALIAS_ICON%>:
		</td>		
		<td>
		<form:input path="icon" id="icon" cssClass="" maxlength="50" />
		</td>
	</tr>	
	
	<tr>	
		<td class="tdLabel">
			<%=Menu.ALIAS_MENU_NAME%>:
		</td>		
		<td>
		<form:input path="menuName" id="menuName" cssClass="" maxlength="50" />
		</td>
	</tr>	
	
	<tr>	
		<td class="tdLabel">
			<%=Menu.ALIAS_PARENT_NAME%>:
		</td>		
		<td>
		<%--
		<form:input path="parentId" id="parentId" cssClass="" maxlength="50" />
		 --%>
		<form:input path="parentName" id="parentName" readonly="true"/>
		<form:hidden path="parentId" id="parentId"/>
		<input type="button" id="h" value="选择树" onclick="openTree('${menu.parentId}')"/>
		<%--
		<input type="hidden" id="parentId" name="parentId"/>
    	<form:input path="parentId"  id="parentId" value="窗口的值返回到这里"/>
		<input value="${menu.parentId}" onclick="WdatePicker({dateFmt:'<%=Menu.FORMAT_BIRTH_DATE%>'})" id="birthDateString" name="birthDateString"  maxlength="0" class="" />
		 --%>
		</td>
	</tr>	
	
	<tr>	
		<td class="tdLabel">
			<%=Menu.ALIAS_URL%>:
		</td>		
		<td>
		<form:input path="url" id="url" cssClass="validate-integer " maxlength="4" />
		</td>
	</tr>	
	
	</table>
</form:form>
</body>
</html>